Skip to content

Birmingham | ITP-Jan | Ahmad Roman Sanaye | Sprint 3 | Implement functions and rewrite tests #1119

Open
RomanSanaye wants to merge 12 commits intoCodeYourFuture:mainfrom
RomanSanaye:coursework/sprint-3-implement-and-rewrite
Open

Birmingham | ITP-Jan | Ahmad Roman Sanaye | Sprint 3 | Implement functions and rewrite tests #1119
RomanSanaye wants to merge 12 commits intoCodeYourFuture:mainfrom
RomanSanaye:coursework/sprint-3-implement-and-rewrite

Conversation

@RomanSanaye
Copy link

@RomanSanaye RomanSanaye commented Mar 1, 2026

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

  • Updated getCardValue function to properly validate card ranks using /^[JQK]$/ for face cards instead of /J|Q|K/.
  • Added Jest tests for edge cases mentioned by the reviewer: "0x02♠", "QQ♠", "2.1♠".
  • Refactored existing tests for clarity and full coverage of:
    • Ace cards (A)
    • Number cards (2–10)
    • Face cards (J, Q, K)
    • Invalid cards
  • Formatted the get-angle-type code using Prettier extension for consistent style.
  • Completed the second part of the Implement and Rewrite Test folder, including proper test coverage and organization.

Testing

  • All Jest tests pass locally, including the new edge case tests.

@github-actions

This comment has been minimized.

@RomanSanaye RomanSanaye added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 1, 2026
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exercise has a second part, where you are expected to implement Jest tests on the files in Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest.


Can you also include a Changelist section in the PR description?

// TODO: Implement this function
if(numerator <= 0 || denominator <= 0){
return false;
}else if(numerator < denominator){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check if 1/-2, -1/2, -1/-2 are consider proper fractions, and then update the implementation and tests accordingly?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the suggestion — it was very useful. I checked 1/-2, -1/2, and -1/-2; all are proper fractions. I updated the isProperFraction function and tests using Math.abs() to handle these cases.

Comment on lines +38 to +40
}else if(rank.match(/J|Q|K/)){
return 10;
}else if(rank.match(/^(10|[2-9])$/)){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does your function return the value you expected from each of the following function calls?

getCardValue("0x02♠");
getCardValue("QQ♠");
getCardValue("2.1♠");

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pointing this out. I have tested the function with getCardValue("0x02♠"), getCardValue("QQ♠"), and getCardValue("2.1♠"); all now correctly throw an "Invalid card" error as expected. I also added Jest tests to cover these edge cases.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 9, 2026
@github-actions

This comment has been minimized.

clear Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this file is not related to the exercise, please remove it to keep the PR branch clean.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you address this comment?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are talking about (isproperFracction) then it is part of the exercises. other case, I did not get what you are pointing at.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment can also be left on a file.
There is a file named "clear" in the top-level folder.

image

You can also view all the "changed files" on this PR branch by clicking the "Files changed" tab:
image

@RomanSanaye RomanSanaye added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 19, 2026
@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants